﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SignLockerTest
{
    class Utility
    {
        public static double ComputeDegre(CatchedPoint p1, CatchedPoint p2, CatchedPoint p3)
        {
            if ((p1.X == p2.X && p2.X != p3.X) || (p1.Y == p2.Y && p2.Y == p3.Y))
                return Math.PI;
            else
            {
                double a = (p3.X - p2.X) * (p3.X - p2.X) + (p3.Y - p2.Y) * (p3.Y - p2.Y);
                double b = (p3.X - p1.X) * (p3.X - p1.X) + (p3.Y - p1.Y) * (p3.Y - p1.Y);
                double c = (p2.X - p1.X) * (p2.X - p1.X) + (p2.Y - p1.Y) * (p2.Y - p1.Y);
                if (a * c == 0) return 0;
                return Math.Acos((a + c - b) / (2 * Math.Sqrt(c) * Math.Sqrt(a)));
            }
        }
    }

    class CatchedPoint
    {
        public double X { get; set; }
        public double Y { get; set; }

        public CatchedPoint() { }

        public CatchedPoint(double x, double y)
        {
            this.X = x;
            this.Y = y;
        }
    }
}
